home *** CD-ROM | disk | FTP | other *** search
- Path: cypher.3do.com!user
- From: tsw@3do.com (Tom Watson)
- Newsgroups: comp.lang.c
- Subject: Re: Q about the float point format......
- Date: Thu, 21 Mar 1996 14:42:17 -0800
- Organization: The 3DO Corporation
- Distribution: world
- Message-ID: <tsw-2103961442170001@cypher.3do.com>
- References: <s3032089.15.314E68DD@sparc13.ncu.edu.tw> <4imhl7$jcf@news.xs4all.nl>
- NNTP-Posting-Host: cypher.3do.com
-
- In article <4imhl7$jcf@news.xs4all.nl>, falstaff@xs4all.nl (Falstaff) wrote:
-
- > s3032089@sparc13.ncu.edu.tw (Alexander PeaceLand) writes:
- >
- >
- > > Could I dynamicly set the digits after the float POINT?
- >
- > > In other word... I use printf to print the float point number
- > > like 123.456789 but in the other time i only
- > > want to print 123.456 or 123.4
- > > How shall I do? Thanks! :)
- >
- > i=3; /* or whatever */
- > printf("%.*f",123.456789,i);
- >
- > That should work.
- >
-
-
- The spirit is willing, the body is weak...
-
- Arguments reversed to printf! The argument for the '*' needs to come
- first, so it should be:
- i=3; /* or whatever */
- printf("%.*f", i, 123.456789);
- The idea is good though!!
-
- Yes, I tried it with my compiler!!
-
- --
- Tom Watson
- tsw@3do.com (Home: tsw@johana.com)
-